package com.turkline.CatchMePolygon;

import java.util.List;

import org.w3c.dom.Element;

import android.graphics.Rect;

import com.badlogic.androidgames.framework.Sound;
import com.badlogic.androidgames.framework.gl.Font;
import com.badlogic.androidgames.framework.gl.FontBatcher;
import com.badlogic.androidgames.framework.gl.Texture;
import com.badlogic.androidgames.framework.gl.TextureRegion;
import com.badlogic.androidgames.framework.impl.GLGame;
import com.badlogic.androidgames.framework.math.Rectangle;

public class Assets
{
	//**********************************************************************************************************/
	//----------------------------------------------------Button Regions---------------------------------------/
	public static Rectangle playButtonRectangle = new Rectangle(300, 100, 225, 95);
	public static Rectangle restartRect = new Rectangle(165, 70, 230, 70);
	public static Rectangle toMenu = new Rectangle(0, 272, 256, 64);
	public static Rectangle toMainMenu = new Rectangle(272, 48, 256, 64);
	public static Rectangle[] levelNumRect = new Rectangle[20];
	public static Rectangle helpClose = new Rectangle(635, 384, 80, 70);
	public static Rectangle soundButton = new Rectangle(320, 0, 80, 60);
	public static Rectangle helpButton = new Rectangle(400, 0, 80, 60);
	public static Rectangle gameEndClose = new Rectangle(633, 147, 80, 70);
	//----------------------------------------------------------------------------------------------------------/
	
	
	//**********************************************************************************************************/
	//----------------------------------------------------Texture / TextureRegion-------------------------------/
	public static Texture items;
	public static Texture items2;
	public static TextureRegion backRegion;
	public static TextureRegion logoRegion;
	public static TextureRegion logoLeftRegion;
	public static TextureRegion logoRightRegion;
	
	public static TextureRegion playButtonRegion;
	public static TextureRegion playButtonDownRegion;
	public static TextureRegion controlButtonsRegion;
	public static TextureRegion controlButtonSoundRegion;
	public static TextureRegion controlButtonSoundOffRegion;
	public static TextureRegion controlButtonHelpRegion;
	public static TextureRegion blockRectRegion;
	public static TextureRegion connecterRegion;
	public static TextureRegion blockBlueRegion;
	public static TextureRegion blockYellowRegion;
	public static TextureRegion blockGreenRegion;
	public static TextureRegion blockLBlueRegion;
	public static TextureRegion blockOrangeRegion;
	public static TextureRegion blockRedRegion;
	public static TextureRegion finishScreenRegion;
	public static TextureRegion startScreenRegion;
	public static TextureRegion[] levelSelectNumRegion;
	public static TextureRegion levelSelectSqRegion;
	public static TextureRegion toMainMenuRegion;
	public static TextureRegion lockedRegion;
	public static TextureRegion[] medalRegion;
	
	public static TextureRegion scoreBoxRegion;
	public static TextureRegion medalBoxRegion;
	public static TextureRegion playAgainRegion;
	public static TextureRegion playNextRegion;
	public static TextureRegion levelEndRegion;
	public static TextureRegion levelEndWhiteRegion;
	public static TextureRegion levelEndGoldMedal;
	public static TextureRegion levelEndSilverMedal;
	public static TextureRegion levelEndBronzeMedal;
	public static TextureRegion helpRegion;
	public static TextureRegion gameEndMessage;
	
	public static TextureRegion loadingSign;
	public static TextureRegion loadingDot;
	
	//---------------------------------------------------------------------------------------------------------/
	//**********************************************************************************************************/
	public static Sound clickSound;
	public static Sound stepSound;
	//**********************************************************************************************************/
	//----------------------------------------------------Font--------------------------------------------------/
	public static Font font;
	public static XmlManager xmlManagerBigScore;
	public static XmlManager xmlManagerSmallScore;
	public static FontBatcher fontBatcherBigScore;
	public static FontBatcher fontBatcherSmallScore;
	//----------------------------------------------------Font--------------------------------------------------/
	
	
	public static List<Element> bigScoreGypsList;
	public static List<Element> smallScoreGypsList;
	
	
	public static void load(GLGame game)
	{
		items = new Texture(game, "atlas.png");
		items2 = new Texture(game, "atlas2.png");
		backRegion = new TextureRegion(items, 0, 0, 800, 480);
		logoRegion = new TextureRegion(items, 0, 512, 640, 160);
		
		logoLeftRegion = new TextureRegion(items2, 0, 832, 512, 192);
		logoRightRegion = new TextureRegion(items2, 512, 832, 352, 192);
		
		playButtonRegion = new TextureRegion(items, 0, 672, 224, 96);
		playButtonDownRegion = new TextureRegion(items, 0, 768, 224, 96);
		controlButtonsRegion = new TextureRegion(items, 224, 672, 192, 96);
		controlButtonSoundRegion = new TextureRegion(items, 320, 768, 64, 64);
		controlButtonSoundOffRegion = new TextureRegion(items, 384, 768, 64, 64);
		controlButtonHelpRegion = new TextureRegion(items, 0, 512, 64, 64);
		blockRectRegion = new TextureRegion(items, 0, 480, 32, 32);
		connecterRegion = new TextureRegion(items, 224, 480, 32, 32);
		blockBlueRegion = new TextureRegion(items, 32, 480, 32, 32);
		blockYellowRegion = new TextureRegion(items, 64, 480, 32, 32);
		blockGreenRegion = new TextureRegion(items, 96, 480, 32, 32);
		blockLBlueRegion = new TextureRegion(items, 128, 480, 32, 32);
		blockOrangeRegion = new TextureRegion(items, 160, 480, 32, 32);
		blockRedRegion = new TextureRegion(items, 192, 480, 32, 32);
		finishScreenRegion = new TextureRegion(items, 224, 768, 256, 192);
		startScreenRegion = new TextureRegion(items, 224, 960, 256, 64);
		levelSelectNumRegion = new TextureRegion[20];
		for(int i = 0; i < 20; i++) {
			int x = 864+((i%5) *32);
			int y = (i/5)*32;
			levelSelectNumRegion[i] = new TextureRegion(items, x, y, 31, 32);
		}
		levelSelectSqRegion = new TextureRegion(items, 801, 1, 62, 62);
		toMainMenuRegion = new TextureRegion(items, 224, 896, 256, 64);
		lockedRegion = new TextureRegion(items, 801, 64, 30, 32);
		medalRegion = new TextureRegion[3];
		for(int i = 0; i < 3; i++) {
			medalRegion[i] = new TextureRegion(items, 864 + i*32 ,128, 32, 64);
		}
		font = new Font(items,640,480,16,16,16);
		for(int i = 0; i < 20; i++) {
			levelNumRect[i] = new Rectangle(((i%10)*78)+17, 328-(i/10)*90, 64, 64);
		}
		
		helpRegion = new TextureRegion(items2, 0, 384, 736, 448);
		
		levelEndRegion = new TextureRegion(items, 480, 672, 544, 320);
		scoreBoxRegion = new TextureRegion(items, 800, 320, 224, 64);
		medalBoxRegion = new TextureRegion(items, 800, 384, 224, 64);
		playAgainRegion = new TextureRegion(items, 800, 192, 224, 64);
		playNextRegion = new TextureRegion(items, 800, 256, 224, 64);
		levelEndWhiteRegion = new TextureRegion(items, 224, 768, 32, 32);
		levelEndGoldMedal = new TextureRegion(items2, 832, 0, 64, 96);
		levelEndSilverMedal = new TextureRegion(items2, 896, 0, 64, 96);
		levelEndBronzeMedal = new TextureRegion(items2, 960, 0, 64, 96);
		gameEndMessage = new TextureRegion(items2, 0, 96, 736, 224);
		loadingSign = new TextureRegion(items2, 0, 320, 800, 64);
		loadingDot = new TextureRegion(items2, 736, 288, 32, 32);
		
		stepSound = game.getAudio().newSound("adim.ogg");
		clickSound = game.getAudio().newSound("click.ogg");
		
		xmlManagerBigScore = new XmlManager(game, "scoreFontBig.fnt");
		fontBatcherBigScore = new FontBatcher(items, 0, 864 , xmlManagerBigScore.XML_DATA);
		xmlManagerSmallScore  = new XmlManager(game, "scoreFontSmall.fnt");
		fontBatcherSmallScore = new FontBatcher(items2, 0, 0, xmlManagerSmallScore.XML_DATA);
	}
	
	public static void reload(GLGame game)
	{
		items.reload();
		items2.reload();
	}
	
	public static void playSound(Sound sound) {
		if(Settings.soundEnabled)
			sound.play(1);
	}
}
